const MbimCliParser = require("../mbimcli-tools").MbimCliParser;

const mbimcli = new MbimCliParser();

// 需要重新启动网络
// ifconfig wwan0 down
// ifconfig wwan0 upls
 /**
         * 1. Querying subscriber ready status 
         * 'mbimcli -d /dev/cdc-wdm0 --query-subscriber-ready-status --no-close '...
         * [/dev/cdc-wdm0] Subscriber ready status retrieved: Ready state: 'initialized' Subscriber ID: '460077011945596' SIM ICCID: '898600A001210006201' Ready info: 'none' Telephone numbers: (0) 'unknown' [/dev/cdc-wdm0] Session not closed: TRID: '3'
         * Saving state at /tmp/mbim-network-state-cdc-wdm0... (TRID: 3)
         * 
         */
/*
  mbimcli.query_subscriber_ready_status()
         .then(({code,trid,inited})=>{
             console.log(code,parseInt(trid),inited);
         }).catch((e)=>{
             console.log(e);
         });
*/
 /**
   * 2. Querying registration state
   * 'mbimcli -d /dev/cdc-wdm0 --query-registration-state --no-open=3 --no-close '...
   * [/dev/cdc-wdm0] Registration status: Network error: 'unknown' Register state: 'home' Register mode: 'automatic' Available data classes: 'lte' Current cellular class: 'gsm' Provider ID: '46000' Provider name: 'CMCC' Roaming text: 'unknown' Registration flags: 'packet-service-automatic-attach' [/dev/cdc-wdm0] Session not closed: TRID: '4'
   * Saving state at /tmp/mbim-network-state-cdc-wdm0... (TRID: 4)
 */
/*
console.log("query_registration_state.");
mbimcli.query_registration_state(3)
         .then(()=>{
             //console.log(code,parseInt(trid),inited);
         }).catch((e)=>{
             console.log(e);
         });
*/
  /**
   * 3. Attaching to packet service with 
   * 'mbimcli -d /dev/cdc-wdm0 --attach-packet-service --no-open=4 --no-close '...
   * Saving state at /tmp/mbim-network-state-cdc-wdm0... (TRID: 5)
   */
/*  console.log("attach_package_service")
   mbimcli.attach_packet_service(4)
         .then(()=>{
             //console.log(code,parseInt(trid),inited);
         }).catch((e)=>{
             console.log(e);
         });

  /**
   * 4. Starting network with
   * 'mbimcli -d /dev/cdc-wdm0 --connect=apn='cmnet' --no-open=5 --no-close '...
   * Network started successfully
   * Saving state at /tmp/mbim-network-state-cdc-wdm0... (TRID: 7)
   */

  console.log("start network");
   mbimcli.start_network(5)
         .then(()=>{
             //console.log(code,parseInt(trid),inited);
         }).catch((e)=>{
             console.log(e);
         });

